/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author wssccc
 */
public class MyCmdParser {
    public static Method getInterrupter(String cmdhead) throws NoSuchMethodException
    {
        return Interrupter.class.getMethod(cmdhead, String.class);
        
        
    }
    public static void ParseCommand(String cmd)
    {
        System.out.println("code is "+cmd);
        String command_head=cmd.substring(0,1);
        String command_param=cmd.substring(1);
        try {
            try {
                getInterrupter(command_head).invoke(null,command_param);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(MyCmdParser.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalArgumentException ex) {
                Logger.getLogger(MyCmdParser.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InvocationTargetException ex) {
                Logger.getLogger(MyCmdParser.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (NoSuchMethodException ex) {
            Logger.getLogger(MyCmdParser.class.getName()).log(Level.SEVERE, null, ex);
        }
   }
}
